package com.yr.ryjk.coin;

import java.util.Map;

import org.hibernate.validator.constraints.NotBlank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yr.ryjk.coin.service.ICoinService;
import com.yr.ryjk.interceptor.authority.For;
import com.yr.ryjk.interceptor.authority.UserType;
/**
 * 健康币
 * @author Rick
 *
 */
@For(user=UserType.APP_USER)
@Controller
@RequestMapping("/coin")
@ResponseBody
public class CoinController {
	@Autowired
	private ICoinService coinService;
	
	/**
	 * 用户领取每日健康币
	 * @param token
	 * @return
	 */
	@RequestMapping(value="/takeTodayCoin",method=RequestMethod.GET)
	public Map<String, Object> takeTodayCoin(@RequestParam("token") @NotBlank String token){
		return coinService.updateTakeTodayCoin(token);
	}
	
	/**
	 * 分页获取健康币收支记录接口(医生或用户均可)
	 * @param pageNo
	 * @param pageSize
	 * @param token
	 * @return
	 */
	@RequestMapping(value="/coinRecord",method=RequestMethod.GET)
	public Map<String, Object> getCoinRecord(@RequestParam(value="pageNo",defaultValue="1") int pageNo,
			@RequestParam(value="pageSize",defaultValue="10") int pageSize, 
			@RequestParam("token") @NotBlank String token){
		return coinService.getCoinRecord(pageNo,pageSize,token);
	}
	
	
	/**
	 * 用户分享领取健康币
	 * @param token
	 * @return
	 */
	@RequestMapping(value="/shareAppGetCoin",method=RequestMethod.GET)
	public Map<String, Object> shareAppGetCoin(@RequestParam("token") @NotBlank String token){
		return coinService.insertShareAppGetCoin(token);
	}
}
